package cn.liuhuan1.mongoDb.controller;

import cn.liuhuan1.mongoDb.mongoDbImp.MongoDbImp;
import cn.liuhuan1.webModelBean.vo.ArticleCommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther: liuhuan
 * @Date: 2021/4/19 - 04 - 19 - 19:26
 * @Description:
 * @version: 1.0
 */
@Controller
@RequestMapping("/mongoDb")
public class MongoDbController {

    @Autowired
    private MongoDbImp mongoDbImp;

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    @ResponseBody
    public void insert(@RequestBody ArticleCommentVo articleCommentVo){
        mongoDbImp.inser(articleCommentVo);
    }

    @RequestMapping(value = "/insertList",method = RequestMethod.POST)
    @ResponseBody
    public void insertList(@RequestBody List<ArticleCommentVo> articleCommentVoList){
        mongoDbImp.inserList(articleCommentVoList);
    }
    @RequestMapping(value = "/findAll",method = RequestMethod.GET)
    @ResponseBody
    public List<ArticleCommentVo> findAll(@RequestParam("articleId") String articleId){
        List<ArticleCommentVo> mongoDbImpAll = mongoDbImp.findAll(articleId);
        return mongoDbImpAll;
    }

    @RequestMapping(value = "/likeNumber",method = RequestMethod.POST)
    @ResponseBody
    public void likeNumber(@RequestParam("id") String id,
                           @RequestParam("likeNumber") Integer likeNumber){
        mongoDbImp.updateLikeNumber(id,likeNumber);
    }

}
